home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-15 | 7.6 KB | 266 lines | [TEXT/MPS ] |
- ======================================
- all version nrs refer to scheduler.inc
- ======================================
- ===============================================
- How to move from Scheduler 0.9 to Scheduler 1.x
- ===============================================
- Change event loop:
- replace call to Scheduler.task by call to Scheduler.PeriodicTask.
- add NetWorkEvents in the event loop case list:
- {*******************}
- NetWorkEvt: Scheduler.HandleMsg(MsgPtr(message));
- {*******************}
- Change NewTask.
- the defaults are now passed in a MsgRec structure. Use inherited NewTask instead of
- reading the scheduler fields.
- Revise buffer handling.
- Instead of a latched buffer, buffer handling now is done by procedures.
- See remark for 1.1-7.
-
- ===============================================
- History
- ===============================================
-
- renamed scheduler.inc to scheduler.inc.p for Mouser/MacBrowse
- ======
- 1.1-0E
- ======
- change parameter from ptr to handle in MemberKludge.
-
- ======
- 1.1-0D
- ======
- corrected MemberKludge to account for two byte header in object data structure.
- introduced GetSleep.
-
- ======
- 1.1-0C
- ======
- changed delay from integer to longint.
- renamed cohandler fields
- TaskAddr: MsgAddr; {the effective address of the task server}
- TaskId: longint; {a stamp to identify the task.}
- TaskIterations: longint; {the number of elementary actions to perform}
- introduced variable for send memory
- PrevDest: MsgAddr; {the last destination a task was sent to}
- removed network initialization
- delays changed to longint, reviewed used of cohandler and transportptr
- additional comments; cleaned up NewTask
- correction of address handling in DoNewTask
- added source info in debugger messages
-
- ======
- 1.1-9
- ======
- removed Scheduler.TaskGeneratorNeedsAttention. Is done by periodicTask.
- added special casing for zero length buffers at various places.
-
- ======
- 1.1-8
- ======
- removed tScheduler.task. Old code is included below. Replaced by PeriodicTask
- removed SetMsgBuffers, SetMsgDataBuffers. Old code is included below.
-
- ======
- 1.1-7
- ======
- removed field:
- UserRefMessage:MessagePtr;
- from tMessageHandler object.
- No generic use for this field. Can be added by user in descendants if needed.
- If this field is needed, tMessageHandler.init should include
- UserRefMessage:=nil;
-
- Instead of UserRefMessage, a method is recommended:
- Procedure SetMsgDefaults(msg:MsgPtr);
- with default to
- Procedure tMessageHandler.SetMsgDefaults(msg:MsgPtr);
- begin
- with msg^ do
- begin
- MsgTrpPtr:=nil;
- MsgUserRefCon:=longint(nil);
-
- MsgSource:=Scheduler.Myself;
- MsgDest:=Scheduler.Myself;
- MsgReply:=Scheduler.Myself;
- MsgCapasVerb:=cAnyCapas;
- MsgReference:=0;
- MsgPrioSize:=0;
- MsgStdSize:=0;
- MsgPrioPtr:=nil;
- MsgStdPtr:=nil;
-
- end;
- end;
-
-
- removed from tTaskHandler:
- {--------- addresses and pointers for incoming messages -------------}
-
- PriorityBuffer :ptr;
- MaxPrioritySize :size;
- DataBuffer :ptr;
- MaxDataSize :size;
- Added contructors/destructors for buffer handling instead.
- The use of latched pointers offered itself to poor buffer strategies.
- for a transition, the latched version can be translated into a function
- base version using
- function tmyMessageHandler.NewPrioPtr(var PrioSize:longint):ptr;override;
- begin
- if PrioSize>MaxPrioritySize then PrioSize:=MaxPrioritySize;
- NewPrioPtr:=PriorityBuffer;
- end;
-
- function tmyMessageHandler.NewStdPtr(var StdSize:longint):ptr;override;
- begin
- if StdSize>MaxDataSize then StdSize:=MaxDataSize;
- NewStdPtr:=DataBuffer;
- end;
-
- procedure tmyMessageHandler.DisposPrioPtr(var PrioPtr:Ptr);override;
- begin
- PrioPtr:=nil;
- end;
-
- procedure tmyMessageHandler.DisposStdPtr(var StdPtr:Ptr);override;
- begin
- StdPtr:=nil;
- end;
-
- removed
- procedure tScheduler.KillMsg (Msg : MsgPtr);
- procedure tScheduler.ReceiveMsg (Msg : MsgPtr);
- from public and made it internal function of HandleMsg.
-
- ======
- 1.1-6
- ======
- renamed
- tTaskHandler.MsgInContext to MsgHeaderUseable.
- This function should use only make use of header information to check an
- incoming message.
-
- removed
- function ReceiverNeedsAttention: boolean;
- from scheduler. All queue handling is now done by the NetWork processor.
- If needed, ReceiverNeedsAttention cold be implemented by checking for pending
- NetWork events.
-
- ===================
- old code fragments
- ===================
-
- -------------------------------------
- from 0.9b1. replaced by periodictask.
- -------------------------------------
- procedure tScheduler.task;
- const timetospend=10;{ticks allowed for receive}
- var
- timeout:longint;
- destinationaddr:MsgAddr;x:integer;
- begin
- periodicTask(x);
- debugstr('schduler.task is obsolete. use periodicTask');
- {$IFC false}
- {make sure handlers are installed. needed for Housekeeping ? else later}
- if TaskHandler=nil then receiving:=false;
- if TaskGenerator=nil then sending:=false;
-
-
- timeout:=tickcount+timetospend;
- if receiving
- then
- while (tickcount<timeout) & ReceiverNeedsAttention do
- with TaskHandler do begin
-
- {$IFC debugging} if spare then debugstr('tScheduler.task receiver needs attention;g'); {$ENDC}
- if RecDataAccepted then {old message arrived & Housekeeping handled errors}
- begin
- {$IFC debugging} if spare then debugstr('tScheduler.task evaluate old;g');{$ENDC}
-
- MsgEvaluation(RecMsgPtr);
- handleError(pUndefined,DestroyMsg(RecMsgPtr));{the user had a chance…}
- RecMsgPtr:=nil;{not our business anymore}
- RecDataAccepted:=false;
- end
- else {check for new message}
- begin
- {handleError(pUndefined,msgStatus(RecMsgPtr));}
- if (RecMsgPtr<>nil) & (msgStatus(RecMsgPtr)=0) then
- begin {valid new message}
-
- if TaskHandler.MsgHeaderUseable(RecMsgPtr)
- &
- (TaskHandler.MsgUseable(RecMsgPtr)) then
- {start receiving it}
- begin
- if CoHandler<>nil then
- CoHandler.Cohandle(pUseable,RecMsgPtr);
- {$IFC debugging} if spare then debugstr('scheduler task: msg is useable;g'); {$ENDC}
-
- if (DataBuffer=nil) & (MaxDataSize<>0) then handleError(pUndefined,cNilError);
-
- handleError(pAcceptMsg,AcceptMsg(RecMsgPtr,
- DataBuffer,
- MaxDataSize));
-
- RecDataAccepted:=false;
-
- RecMsgPtr:=nil;
- end
- else
- {dispose useless message}
- begin
- if CoHandler<>nil then
- CoHandler.Cohandle(pUnUseable,RecMsgPtr);
- {?? should we avoid calling it for msgs out of context ?}
- {$IFC debugging} if spare then debugstr('scheduler task: msg is useless;g'); {$ENDC}
- handleError(pUndefined,DestroyMsg(RecMsgPtr));{the user had a chance…}
- RecMsgPtr:=nil;{not our business anymore}
- RecDataAccepted:=false;
- end;{dispose useless message}
- end;{valid new message}
-
- end; {check for new message}
- end;{receiving}
-
-
- {make sure handlers are installed -someone may have changed it}
- if TaskGenerator=nil then sending:=false;
-
- if sending & TaskGeneratorNeedsAttention then
- begin
-
- Destination.a:={NLNext(Destination.a)}NLRandom;
- destinationaddr:=destination;
- DoNewTask(destinationaddr);
- end;{TaskGeneratorNeedsAttention}
- {$ENDC}
- end;
-
- -------------------------------------
- from 0.9b1. not of general use.
- -------------------------------------
- Procedure SetMsgBuffers(msg: MsgPtr;PrioBuf:Ptr;MaxPrioSize:Size;DataBuf:Ptr;MaxDataSize:Size);
- Procedure SetMsgDataBuffer(msg: MsgPtr;DataBuf:Ptr;MaxDataSize:Size);
- Procedure SetMsgBuffers(msg: MsgPtr;PrioBuf:Ptr;MaxPrioSize:Size;DataBuf:Ptr;MaxDataSize:Size);
- begin
- if msg<>nil then with msg^ do
- begin
- MsgPrioPtr:=PrioBuf;
- MsgPrioSize:=MaxPrioSize;
- MsgStdPtr:=DataBuf;
- MsgStdSize:=MaxDataSize;
- end;
- end;
-
- Procedure SetMsgDataBuffer(msg: MsgPtr;DataBuf:Ptr;MaxDataSize:Size);
- begin
- if msg<>nil then with msg^ do
- begin
- MsgStdPtr:=DataBuf;
- MsgStdSize:=MaxDataSize;
- end;
- end;
-